const express = require('express');
const router = express.Router();
const Mock = require('mockjs');        //引入mock模块

/**
 * This function comment is parsed by doctrine
 * @route GET /mock/get
 * @summary mock - test Mock
 * @group mock - 组2注释
 * @param {string} user.query.required - username
 * @param {number} password.query.required - username
 * @returns {object} 200 - An array of user info
 * @returns {Error}  default - Unexpected error
 */
router.get('/get', (req, res, next) => {
    const { user, password } = req.query;

    console.log({ user, password })

    res.json(Mock.mock({
        "status": 200,
        "data|1-5": [{
            "name|5-8": /[a-zA-Z]/,
            "id|+1": 1,
            "value|0-500": 20,
            "boolean|1-2": true,
            "id": "@guid",
            "img": "@image('200x100')",
            "date": "@datetime('yyyy-MM-dd HH:mm:ss')",
            "date2": "@datetime('yyyy-MM-dd')",
            "query": "@paragraph(1)",
            "query2": () => user,

            "object|1": [
                "AMD",
                "CMD",
                "UMD"
            ]
        }]
    }));
});

module.exports = router;